package code.android.iMemorizer.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class LoginActivity extends Activity
{
	public static final String DEBUG_TAG = "LoginActivity"; 
	
	Button mEmptyAllButton = null;
	Button mLoginOKButton = null;
	EditText mIDEditText = null;
	EditText mPWDEditText = null;
	Context mem = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{

		Log.i(DEBUG_TAG, "OnCreate()");
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login_view);
		
		mem = getApplicationContext();
		
		mEmptyAllButton = (Button) findViewById(R.id.Button_empty);
		mLoginOKButton = (Button) findViewById(R.id.Button_ok);
		mIDEditText = (EditText) findViewById(R.id.EditText_ID);
		mPWDEditText = (EditText) findViewById(R.id.EditText_Password);
		
		mLoginOKButton.setOnClickListener( new View.OnClickListener() 
		{
			
			@Override
			public void onClick(View v) 
			{
				Intent i = new Intent();
				
				i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				i.setClass(getApplicationContext(), code.android.iMemorizer.activity.RootActivity.class);
				
				startActivityForResult(i, 1);
			}
		});
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) 
	{
		Log.i(DEBUG_TAG, "OnActivityResult()");
		if(requestCode == 0)
		{
			finish();
		}
			
		super.onActivityResult(requestCode, resultCode, data);
	}
	
	  @Override
	    protected void onPause() 
	    {
	    	Log.i(DEBUG_TAG, "OnPause()");
	    	super.onPause();
	    }
	    
	    @Override
	    protected void onStart() 
	    {
	    	Log.i(DEBUG_TAG, "OnStart()");
	    	super.onStart();
	    }
	    
	    @Override
	    protected void onResume() 
	    {
			Intent i = new Intent();
			
			i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			i.setClass(this, code.android.iMemorizer.activity.RootActivity.class);
			
			startActivity(i);
	    	
	    	Log.i(DEBUG_TAG, "OnResume()");
	    	super.onResume();
	    }
	    
	    @Override
	    protected void onStop() 
	    {
//	    	finish();
	    	Log.i(DEBUG_TAG, "OnStop()");
	    	super.onStop();
	    }
	    
	    @Override
	    protected void onRestart() 
	    {
	    	Log.i(DEBUG_TAG, "OnRestart()");
	    	super.onRestart();
	    }
	    
	    @Override
	    protected void onDestroy() 
	    {
	    	Log.i(DEBUG_TAG, "OnDestroy()");
	    	super.onDestroy();
	    }
	    
	    @Override
	    public void onConfigurationChanged(Configuration newConfig) 
	    {
	    	Log.i(DEBUG_TAG, "OnConfigurationChanged()");
	    	super.onConfigurationChanged(newConfig);
	    }
}
